package com.wnhz.work.yz.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.wnhz.work.yz.BaseActivity;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.adapter.ProjectScheduleAdapter;
import com.wnhz.work.yz.bean.ProjectScheduleBean;

import java.util.ArrayList;
import java.util.List;

/**
 * ---项目进度
 */
public class ProjectScheduleActivity extends BaseActivity implements View.OnClickListener {
    private TextView title;
    private ListView my_listView;
    private List<ProjectScheduleBean> beanList = new ArrayList<>();
    private ProjectScheduleAdapter mAdapter;

    private String[] types = {"1", "2", "3", "4"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_project_schedule);

        initData();
        initView();
    }

    private void initData() {
        for (int i = 0; i < types.length; i++) {
            ProjectScheduleBean bean = new ProjectScheduleBean();
            bean.setType(types[i]);

            beanList.add(bean);
        }
    }

    private void initView() {
        title = (TextView) findViewById(R.id.view_main_middle_title);
        title.setText("项目进度");
        findViewById(R.id.btn_main_left).setOnClickListener(this);

        my_listView = (ListView) findViewById(R.id.my_listView);
        mAdapter = new ProjectScheduleAdapter(this, beanList, this);
        my_listView.setAdapter(mAdapter);
    }

    @Override
    public void onClick(View v) {
        Intent intent;
        int index;
        switch (v.getId()) {
            case R.id.btn_main_left:
                finish();
                break;

            //查看
            case R.id.tv_look:
                index = (int) v.getTag();
                if ("4".equals(beanList.get(index).getType())) {
                    intent = new Intent(this, ExamineLogisticsActivity.class);
                    startActivity(intent);
                } else {
                    MyToast("查看");
                }
                break;

            //发货清单
            case R.id.tv_inventory:
                intent = new Intent(this, SendGoodsActivity.class);
                startActivity(intent);
                break;

            default:
                break;
        }
    }
}
